﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Web.Mvc;
using System.Reflection;

namespace Lilium.Web.Mvc
{
	[Obsolete("Использовать соответсвующий класс из MVC")]
	public class EntityActionDescription
	{
		public EntityActionDescription(string actionName, EntityActionType actionType, Type entityType, IEnumerable<ActionParameter> parameters)
		{
			if (parameters == null) throw new ArgumentNullException("parameters");
			if (entityType == null) throw new ArgumentNullException("entityType");
        

			m_ActionName = actionName;
			m_ActionType = actionType;
			m_EntityType = entityType;
			m_Parameters = parameters.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
		}

		public ActionParameter FindParameter(string name)
		{
			ActionParameter actionParameter;
			if (m_Parameters.TryGetValue(name, out actionParameter))
				return actionParameter;
			else
				return null;
		}

		#region public string ActionName

		private readonly string m_ActionName;

		public string ActionName
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_ActionName;
			}
		}

		#endregion

		#region public EntityActionType ActionType

		private readonly EntityActionType m_ActionType;

		public EntityActionType ActionType
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_ActionType;
			}
		}

		#endregion

		#region public Type EntityType

		private readonly Type m_EntityType;

		public Type EntityType
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_EntityType;
			}
		}

		#endregion

		#region public IEnumerable<ActionParameter> Parameters

		private readonly Dictionary<string, ActionParameter> m_Parameters;

		public IEnumerable<ActionParameter> Parameters
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_Parameters.Values;
			}
		}

		#endregion
	}
}